<?php
class CardsController extends AppViewController {
	var $name = 'Cards';
	var $helpers = array('Html', 'Form');
   
    var $uses = array("cards");


	function index() {    
        $this->smarty->caching = false;
        $this->smarty->cache_lifetime = 3600*5;
        $this->smarty->assign('SomeValue', "testtest");
        $this->smarty->assign('keywords', "keyword");
        $this->smarty->assign('description', "description");
        $this->smarty->assign('page_title', "page_title");
        $this->smarty->assign('shop_notice', "shop_notice");
        $this->smarty->display('theme/layout.tpl');
        
//		$this->Card->recursive = 0;
//		$this->set("SomeValue", "Called using smarty's renderer.");
	}

	function view($id = null) {
		if (!$id) {
			$this->Session->setFlash(__('Invalid Card.', true));
			$this->redirect(array('action'=>'index'));
		}
		$this->set('card', $this->Card->read(null, $id));
	}

	function add() {
		if (!empty($this->data)) {
			$this->Card->create();
			if ($this->Card->save($this->data)) {
				$this->Session->setFlash(__('The Card has been saved', true));
				$this->redirect(array('action'=>'index'));
			} else {
				$this->Session->setFlash(__('The Card could not be saved. Please, try again.', true));
			}
		}
	}

	function edit($id = null) {
		if (!$id && empty($this->data)) {
			$this->Session->setFlash(__('Invalid Card', true));
			$this->redirect(array('action'=>'index'));
		}
		if (!empty($this->data)) {
			if ($this->Card->save($this->data)) {
				$this->Session->setFlash(__('The Card has been saved', true));
				$this->redirect(array('action'=>'index'));
			} else {
				$this->Session->setFlash(__('The Card could not be saved. Please, try again.', true));
			}
		}
		if (empty($this->data)) {
			$this->data = $this->Card->read(null, $id);
		}
	}

	function delete($id = null) {
		if (!$id) {
			$this->Session->setFlash(__('Invalid id for Card', true));
			$this->redirect(array('action'=>'index'));
		}
		if ($this->Card->del($id)) {
			$this->Session->setFlash(__('Card deleted', true));
			$this->redirect(array('action'=>'index'));
		}
	}

}
?>